<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>班级新增</title>
</head>
<body>
 <form action="<%=request.getContextPath() %>/yecclass/ClassServlet?command=ClassAdd" method="post" onsubmit="return validates();">
       班级名称:<input type="text" name="name" value="" id="name" onblur="upperCase(this)"/>
          <font color="#CCCC66"><span id="printInfo"></span></font>
          <br><br>
          
       关联课程:<select name="course_name" style="width:130px ;align:center"> 
                 <option name="course_name" value=""  > 　全部课程　</option>
                <c:forEach items="${listcourse }" var="positions">
				<option name="course_name" value="${positions.id }"  > 　${positions.course_name }　</option>
				<span id="course_nameInfo"></span>
			</c:forEach></select><br><br>
			
          备　　注:<input type="text" name="memo" value="" id="name"/>
          <span id="nameInfo"></span><br><br>
        <input type="submit" value="新增" onclick="return confirm('是否新增？');">
        <input type="reset" name="button" id="button" value="重置" onClick="return()">
     </form>
     
 <script type="text/javascript">
      //重置功能
    function hanshu(){
	   window.location.href= 'view/sys/class/class-add.jsp'  /*返回本页面*/
	   
	 }
    
      /*用户名唯一验证*/
        function upperCase(name)
      {
        	
       	var xmlhttp;
        var classname = document.getElementById("name").value; 
        
       	if (window.XMLHttpRequest)
       	  {// code for IE7+, Firefox, Chrome, Opera, Safari
       	  xmlhttp=new XMLHttpRequest();
       	  }
       	else
       	  {// code for IE6, IE5
       	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
       	  }
       	xmlhttp.onreadystatechange=function()
       	  {
       	  if (xmlhttp.readyState==4 && xmlhttp.status==200)
       	    {
       		var print = xmlhttp.responseText
       	    document.getElementById("printInfo").innerHTML=print;
       	    }
       	  }
   	  
       	xmlhttp.open("post","<%=request.getContextPath()%>/yecclass/ClassServlet?command=onlyclassname&name="+classname,true);
       	xmlhttp.send();
     }
</script>
</body>
</html>